package com.fy.user.service;


import com.fy.common.api.CommonResult;
import com.fy.user.api.DistributorSpotService;
import com.fy.user.dto.EnterpriseDto;
import com.fy.user.dto.PersonalDto;
import com.fy.user.dto.SettledMerchantDto;
import com.fy.user.entity.EnterpriseEntity;
import com.fy.user.entity.PersonalEntity;
import com.fy.user.entity.SettledMerchantEntity;
import com.fy.user.mapper.DistributorStopMapper;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RequestMapping("/show")
@RestController
public class DistributorSpotServiceImpl implements DistributorSpotService {

    @Resource
    private DistributorStopMapper distributorStopMapper;

    @Override
    @PostMapping(value = "/addPersonal")
    public int addPersonal(PersonalDto personalDto) {
        PersonalEntity personalEntity = new PersonalEntity();
        BeanUtils.copyProperties(personalDto,personalEntity);
        return distributorStopMapper.addPersonal(personalEntity);
    }

    @Override
    @PostMapping(value = "/addEnterprise")
    public int addEnterprise(EnterpriseDto enterpriseDto) {
        EnterpriseEntity enterpriseEntity = new EnterpriseEntity();
        BeanUtils.copyProperties(enterpriseDto,enterpriseEntity);
        return distributorStopMapper.addEnterprise(enterpriseEntity);
    }

    @Override
    @PostMapping(value = "/enter")
    public int enter(SettledMerchantDto settledMerchantDto) {
        SettledMerchantEntity settledMerchantEntity = new SettledMerchantEntity();
        BeanUtils.copyProperties(settledMerchantDto,settledMerchantEntity);
        return distributorStopMapper.enter(settledMerchantEntity);
    }
}
